home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12211 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: linux.nildram.co.uk!usenet
  2. From: colin@greench.co.uk (Colin Wray)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Newbie needs help w/ARGV ARGC
  5. Date: Fri, 29 Mar 1996 21:57:30 GMT
  6. Organization: Greenchurch Software Ltd
  7. Message-ID: <4jhmmn$smd@linux.nildram.co.uk>
  8. References: <4j4ja1$dc3@mtinsc01-mgt.ops.worldnet.att.net>
  9. NNTP-Posting-Host: pppn.nildram.co.uk
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. dslayer@worldnet.att.net (Raymond Joh) wrote:
  13.  
  14. >I have spent three days attempting to determine why my command line
  15. >arguments  are failing...
  16.  
  17. >I am using MS Quick C 2.5
  18.  
  19. >I just want to be able to enter two file paths at the command line.
  20. >Here is my code: 
  21.  
  22. >#include <stdio.h>
  23. >#include <stdlib.h>
  24.  
  25.  
  26.  
  27. >main(int argc, char *argv[],char *envp[])
  28. >{
  29. >FILE *ofp,*nfp;
  30. >char ch;
  31.  
  32. >gets(*argv);
  33. This reads chars from stdin into argv[0] which is :
  34. 1. the program name string
  35. 2. not long enough.
  36. Just omit the 'gets';  argv[1] and argv[2] already hold your two
  37. command line args.
  38. >if (argc!=3)
  39. >  {
  40. >  printf("Enter: <source> <destination>\n");
  41. >  exit(1);
  42. >  }
  43.  
  44. >Code countinues but when I enter my command line input such as:
  45.  
  46. >A:\readme.txt  A:\newfile.txt
  47.  
  48. >I get my arvc error message above
  49. >I'm sure I've missed something simple but it has me stumped.
  50. >(win95 if OS matters.)
  51. >Thanks in Advance!!
  52. >Raymond Joh 
  53. >##############################################################
  54. >Raymond Joh                  If you can't tie a good knot...
  55. >Dslayer@gnn.com                     ...Tie a BUNCH of them!!!
  56. >Dslayer@worldnet.att.net
  57. >Home Page ==>>http://members.aol.com/ggjoh/index.htm
  58. >##############################################################
  59.  
  60.  
  61.  
  62. ----------------------------------------------------------------------------
  63. Colin Wray, Greenchurch Software Ltd, UK
  64. Email: colin@greench.co.uk
  65. ----------------------------------------------------------------------------
  66.  
  67.